﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="BugReplys.aspx.cs" Inherits="BugSysSolution.BugReplys" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="Style/site.css" rel="stylesheet" type="text/css" />
    <link href="Javascript/jquery-ui-1.8.23.custom.css" rel="stylesheet" type="text/css" />
    <script src="Javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="Javascript/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
    <script src="Javascript/common.js" type="text/javascript"></script>
    <style type="text/css">
        #replycontent
        {
            width: 457px;
            height: 206px;
            margin-left: 0px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table id="tab1" class="tab">
            <tr>
                <td colspan="2" align="center">
                    <b>回复信息</b>
                </td>
            </tr>
            <tr>
                <td>
                    标题:<span id="span_title" style="font-size: large"></span>
                </td>
                <td style="text-align: right">
                    回复数:<span id="span_replycount"></span>
                </td>
            </tr>
            <tr>
                <td>
                    创建人:<a id="a1"><span runat="server" id="span_createuser"></span></a>
                </td>
                <td>
                    <div id="txt_content"></div>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: right">
                    <span id="span_date"></span>
                </td>
            </tr>
        </table>
        <table id="tab2" class="tab">
            <asp:Repeater ID="rep" runat="server">
                <ItemTemplate>
                    <tr id='<%# Eval("Id") %>'>
                        <td style="width: 20%">
                            <a userid='<%# Eval("uid") %>' tag="user">
                                <%# Eval("RealName")%>
                            </a>
                        </td>
                        <td>
                            <%# Eval("ReplyContent")%>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="text-align: right" tag="datetime">
                            <%# Eval("ReplyDate")%>
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
            <webdiyer:AspNetPager ID="Pager" runat="server" PageIndexBoxType="TextBox" ShowPageIndexBox="Never"
                SubmitButtonText="" TextAfterPageIndexBox="" TextBeforePageIndexBox="" CurrentPageButtonPosition="End"
                ShowCustomInfoSection="Right" CustomInfoHTML="共%PageCount%页，当前为第%CurrentPageIndex%页，每页%PageSize%条"
                FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" OnPageChanged="Pager_PageChanged"
                PrevPageText="上一页" Direction="LeftToRight" ShowMoreButtons="False" ShowPageIndex="False"
                HorizontalAlign="Right" PageSize="4">
            </webdiyer:AspNetPager>
    </div>
    <br />
    <div style="padding:3px 0px 0px 0px">
        <table id="tab3" class="tab">
            <tr>
                <td>
                    评论:
                </td>
                <td style="text-align:left;width:80%">
                    <textarea id="replycontent" runat="server" style="width:100%"></textarea>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center">
                    <asp:Button CssClass="btn" runat="server" ID="btn_submit" Text="提交" 
                        OnClientClick="return checksubmit();" onclick="btn_submit_Click" />
                </td>
            </tr>
        </table>
    </div>
    <asp:HiddenField ID="HFBUGID" runat="server" />
    </form>
</body>
</html>
<script type="text/javascript">
    var requestUrl = "RequestAjaxPage/BugAjaxPage.aspx";
    var bugid = '<%= Request["bugid"] %>';

    $("#HFBUGID").val(bugid);

    function ChangeDateTime(val) {
        if (val == "") {
            return "";
        }
        var date = new Date(val);
        //alert(date.toLocaleDateString());
        //return date.toLocaleDateString();
    }

    $(function () {
//        $("#tab2 tr td[tag=datetime]").each(function () {
//            $(this).text(ChangeDateTime($(this).text()));
//        })
    })

    function checksubmit() {
        var val = $("#txt_content").text();
        if (val == "") {
            CusDialog.showdialog("错误", "请输入评论内容!", null);
            return false;
        }
        return true;
    }

    function LoadInfo() {
        var id = '<%= Request["bugid"] %>';
        var parm = {
            tag: "gettagbyid",
            id: id,
            ran: Math.random()
        };
        SendAjax("get", requestUrl, parm, "json", function (data) {
            if (data != null) {
                $("#a1").attr("userid", data.CreateUser);
                $("#span_title").text(data.Title);
                $("#span_replycount").text(data.ReplyCount);
                $("#span_createuser").text(data.Realname);
                $("#txt_content").html(data.Contents);
                $("#span_date").text(ChangeDate(data.Createdate));
            } else {
                alert("请求服务器超时!");
                return;
            }
        });
    }

    $("#tab2 tr td a[tag=user]").each(function () {
        $(this).click(function () {
            window.location.href = "../UserInfo/MyInfo.aspx?id=" + $(this).attr("userid");
        })
    })

    $("#a1").click(function () {
        var href = "../UserInfo/MyInfo.aspx?id=" + $("#a1").attr("userid");
        window.location.href = href;
    })

    LoadInfo();
</script>
